function fillAddress() {
	var mail = dwr.util.getValue("mail");
	MailHostAction.getMailHostByMail(mail, function(mailHost) {
		console.info("mailHost"+mailHost);
		dwr.util.setValues(mailHost);
	});
}
function checkMail() {
	var mailHost = {
		id : null,
		mail : null,
		hostName : null,
		userName : null,
		password : null,
		ssl : false,
		kind : null
	};
	dwr.util.getValues(mailHost);
	var mail = dwr.util.getValue("toMail");
	MailHostAction.checkMailByThread(mailHost, mail, function(result) {
		if (map['result'] == "1") {
			alert("恭喜你,当前邮件发送成功,请到相应的邮件里面检测");
		} else {
			alert("对不起,发送错误,错误信息是:," + result);
		}
	});

}
function modify(obj) {

	MailHostAction.getMailHostById(obj.id, function(mailHost) {
		dwr.util.setValues(mailHost);
	});
}
function checkMailFromList(button) {
	var id = button.id.substring(6);
	console.info("id" + id);
	var userName = dwr.util.getValue("userName" + id);
	var mail = dwr.util.getValue("mail" + id);
	var password = dwr.util.getValue("password" + id);
	var hostName = dwr.util.getValue("hostName" + id);
	var ssl = dwr.util.getValue("ssl" + id);
	var mailHost = {
		id : id,
		mail : mail,
		hostName : hostName,
		userName : userName,
		password : password,
		ssl : ssl,
		kind : null
	};
	var toMail = dwr.util.getValue("toMail");
	if (toMail=="") {
		alert("请输入发送的邮箱");
		return;
	}
	MailHostAction.checkMailByThread(mailHost, toMail, function(map) {
		if (map['result'] == "1") {
			$("div" + map['id']).style.color = "blue";
			$("div" + map['id']).innerHTML = map['mail'] + "发送成功";
			$("div" + map['id']).title = "恭喜你,发送成功";
		} else {
			$("div" + map['id']).style.color = "red";
			$("div" + map['id']).innerHTML = map['mail'] + "发送失败";
			$("div" + map['id']).title = "错误信息"+map['result'];
		}
	});
}

function save() {
	var mailHost = {
		id : null,
		mail : null,
		hostName : null,
		userName : null,
		password : null,
		ssl : false,
		kind : null,
		state : null,
		sendOnceMaxCount : null,
		sendDayMaxCount : null
	};
	dwr.util.getValues(mailHost);
	MailHostAction.save(mailHost, function(mailHost) {
		alert("修改成功,请刷新下查看");
	});
}

function chellAll() {
	var toMail = dwr.util.getValue("toMail");
	if (toMail=="") {
		alert("请输入发送的邮箱");
		return;
	}
	var a = document.getElementsByTagName("input");
	for ( var i = 0; i < a.length; i++) {
		if (a[i].name == "checkButton") {
			a[i].click();
			console.info(a[i]);
		}
	}
}